package com.duam.porky.tasks;

import java.util.List;

import com.duam.porky.helpers.PorkyOpenHelper;
import com.duam.porky.model.Concepto;

import android.content.Context;
import android.os.AsyncTask;

public class GrabarConceptosTask extends AsyncTask<List<Concepto>, Integer, Void> 
{
	private Context context;
	private int cantidad;
	
	public GrabarConceptosTask(Context context)
	{
		this.context = context;
	}

	@Override
	protected Void doInBackground(List<Concepto>... params) 
	{
		PorkyOpenHelper helper = new PorkyOpenHelper(context)
		{
			@Override
			protected void itemProccesed() 
			{
				GrabarConceptosTask.this.publishProgress(++cantidad);
			}			
		};
		
		cantidad = 0;
		helper.insertConceptosWithProgress(params[0]);
		
		return null;
	}

}
